<template>
  <van-nav-bar fixed title="今日头条" left-arrow @click-left="onClickLeft">
    <template #right>
      <van-icon name="search" size="18" />
    </template>
  </van-nav-bar>
</template>

<script>
export default {
  name: 'NavBar',
  methods: {
    onClickLeft() {
      if (this.$store.state.homeIsLandingPage) {
        this.$router.go(-1);
      } else {
        this.$router.push({ name: 'Home' }).then(() => {
          this.$store.commit('SET_HOME_IS_LANDING_PAGE', true);
        });
      }
    },
  },
};
</script>
